package cn.itcast.hotel.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class HotelQueueConfig {
    /*
     * 定义交换机*/
    @Bean
    public DirectExchange exchange() {
        return ExchangeBuilder.directExchange("hotel.direct").build();
    }

    /*
     * 定义队列
     * */
    @Bean
    public Queue insert() {
        return QueueBuilder.durable("hotel.insert.queue").build();
    }

    /*
     * 定义队列*/
    @Bean
    public Queue delete() {
        return QueueBuilder.durable("hotel.delete.queue").build();
    }

    /*
     * 定义路由器和队列的绑定*/
    @Bean
    public Binding bindingInsert() {
        Binding binding = BindingBuilder.bind(insert()).to(exchange()).with("hotel.insert");
        return binding;
    }

    /*
     * 定义路由器和队列绑定*/
    @Bean
    public Binding bindingDelete() {
        return BindingBuilder.bind(delete()).to(exchange()).with("hotel.delete");
    }
}
